package com.terrier.ui.controls
{
    import com.terrier.ui.skins.IWxTextInputSkin;

    /**
     * 输入文本区. 它和WxTextInput的区别是,它支持多行输入
     * @author Jarvis.weng
     */
    public class WxTextArea extends WxTextInput
    {
        public function WxTextArea()
        {
            super();
        }

        override protected function initialize():void
        {
            super.initialize();

            _textDisplay.multiline = true;
        }

        override protected function updateLayout():void
        {
            if (_skin == null || !_skin.customLayout)
            {
                var leftPad:Number = skin != null ? skin.leftPad : 0;
                var rightPad:Number = skin != null ? skin.rightPad : 0;
                var topPad:Number = skin != null ? skin.topPad : 0;
                var bottomPad:Number = skin != null ? skin.bottomPad : 0;

                _textDisplay.x = leftPad;
                _textDisplay.y = topPad;

                if (autoSize)
                {
                    measureText(minTextWidth, maxTextWidth, minTextHeight, maxTextHeight);

                    _width = _textDisplay.width + leftPad + rightPad;
                    _height = _textDisplay.height + topPad + bottomPad;
                }
                else
                {
                    _textDisplay.width = _width - leftPad - rightPad;
                    _textDisplay.height = _height - topPad - bottomPad;
                }
            }

            if (skin != null && skin.labelStyle != null)
            {
                skin.labelStyle.applyLayout(_textDisplay);
            }

            _hintTxt.width = _textDisplay.width;
            _hintTxt.height = _textDisplay.height;

            _hintTxt.x = _textDisplay.x;
            _hintTxt.y = _textDisplay.y;

            if (skin != null && skin.hintStyle != null)
            {
                skin.hintStyle.applyLayout(_hintTxt);
            }

            if (_skin == null)
            {
                return;
            }

            _skin.width = _width;
            _skin.height = _height;

            if (_skin.customLayout)
            {
                _width = _skin.width;
                _height = _skin.height;
            }
        }

        private function get skin():IWxTextInputSkin
        {
            return _skin as IWxTextInputSkin;
        }
    }
}
